<?php
/*
 * Created on Feb 2, 2010
 *
 * To change the template for this generated file go to
 * Window - Preferences - PHPeclipse - PHP - Code Templates
 * @package modules\eb_EUVAT\core
 */
 class eb_EUVAT_email extends eb_EUVAT_email_parent
{
    /**
     * Default Smtp server port
     *
     * @var int
     */
    public $SMTP_PORT = 25;

    /**
     * Name of template used by reminder function (article).
     *
     * @var string
     */
    protected $_sReminderMailTemplate = "email_owner_reminder_html.tpl";

    /**
     * Order e-mail for customer HTML template
     *
     * @var string
     */
    protected $_sOrderUserTemplate          = "email_order_cust_html.tpl";

    /**
     * Order e-mail for customer plain text template
     *
     * @var string
     */
    protected $_sOrderUserPlainTemplate     = "email_order_cust_plain.tpl";

    /**
     * Order e-mail for shop owner HTML template
     *
     * @var string
     */
    protected $_sOrderOwnerTemplate         = "email_order_owner_html.tpl";

    /**
     * Order e-mail for shop owner plain text template
     *
     * @var string
     */
    protected $_sOrderOwnerPlainTemplate    = "email_order_owner_plain.tpl";

    // #586A - additional templates for more customizable subjects

    /**
     * Order e-mail subject for customer template
     *
     * @var string
     */
    protected $_sOrderUserSubjectTemplate   = "email_order_cust_subj.tpl";

    /**
     * Order e-mail subject for shop owner template
     *
     * @var string
     */
    protected $_sOrderOwnerSubjectTemplate  = "email_order_owner_subj.tpl";

    /**
     * Price alarm e-mail for shop owner template
     *
     * @var string
     */
    protected $_sOwnerPricealarmTemplate    = "email_pricealarm_owner.tpl";

   
	/**
     * VAT UID VALIDATION EMAIL for customer HTML template
     *
     * @var string
     */
    protected $_sVATHUserTemplate          = "email_vatuid_html.tpl";
    protected $_sVATPUserTemplate          = "email_vatuid_plain.tpl";
    
    
	
    /**
     * Class constructor.
     */
    public function __construct()
    {
        parent::__construct();
    }
    
      

   

    /**
     * Sets mailer additional settings and sends VAT VALIDATION mail to user.
     * Returns true on success.
     *
     * @param oxUser $oUser   User object
     * @param string  $sSubject user defined subject 
     * @param string  $sVatid user defined vatid 
     *
     * @return bool
     */
    public function eb_EUVAT_sendVATEmailToUser( $oUser, $sSubject, $sVatid  )
    {	
        $myConfig = $this->getConfig();
				
        $sCustHTML  = $this->_sVATHUserTemplate;
        $sCustPLAIN = $this->_sVATPUserTemplate;
      	
      	$oShop = $this->_getShop();
 
        // create messages
        $oSmarty = oxUtilsView::getInstance()->getSmarty();
        $oSmarty->assign( "charset", oxLang::getInstance()->translateString("charset"));
		$oSmarty->assign( "user", $oUser );
		$oSmarty->assign( "shop", $oShop );
		$oSmarty->assign( "oViewConf", $oShop );
		
 		$sFullName = $oUser->oxuser__oxfname->value . " " . $oUser->oxuser__oxlname->value;
 		$aNewSmartyArray = array("name" => $sFullName,'vatid' => $sVatid  ,'subject' => $sSubject);
 		foreach ( $aNewSmartyArray as $key => $val ) {
            $oSmarty->assign( $key, $val );
        }
 		$this->setBody( $oSmarty->fetch( $sCustHTML) );
        $this->setAltBody( $oSmarty->fetch( $sCustPLAIN) );
 		$this->setSubject( $sSubject );
 		
 		
		//echo $oUser->oxuser__oxusername->value;
        $this->setRecipient( $oUser->oxuser__oxusername->value, $sFullName );
        $this->setReplyTo( $oShop->oxshops__oxorderemail->value, $oShop->oxshops__oxname->getRawValue() );

        $blSuccess = $this->send();
              
        
        return $blSuccess;
        
    }

   


}
 
?>
